﻿importClass('rapi.rbase.RLabel');

function RMapLabel( latlng, zIndex, text,opacity ){
    this.latlng=latlng;
	this.lat=latlng.lat;
	this.lng=latlng.lng;
	this.text = text;
	this.div = new RLabel(0,0,text).get();
	this.style = this.div.style;
	
	this.div.style.zIndex = zIndex;
	this.style.backgroundColor = '#FFFF00';
	this.style.padding = '2px';
	this.style.border='1px solid #000000';
	
	this.get = function(){
		return this.div;
	}
	this.toString = function(){
	    return "RMapLabel";
	}
	
	this.setText = function(text){
	    this.text = text;
	    if(this.div.innerText){
	        this.div.innerText = text;
	    }else{
	        this.div.textContent=text;
	    }
	    
	}
	
	this.getText = function(){
	    if(this.div.addEventListener){
	        return this.div.textContent;
	    }else{
	        return this.div.innerText;
	    }
	}
	
	this.show = function(){
	    this.div.style.visibility='visible';
	}
	
	this.hide = function(){
	    this.div.style.visibility='hidden';
	}
	
	this.destroy = function(){
		if(this.div.parentNode){
			this.div.parentNode.removeChild(this.div);
		}
	    this.div = null;
	}
	
	this.onclicked = new Array();
	this.addListener=function( listener, estring ){
		switch(estring){
			case 'onclicked':
				if( listener.onclicked ){
					this.onclicked[ this.onclicked.length ] = listener;
				}else{
					window.status=this.toString()+':不合法的'+estring+'事件对象';
				}
			break;
			default:
				window.status=this.toString() + '类不存在'+estring+'事件';
			break;
		}
	}
	
	this.notify=function( estring ){
		switch( estring ){
			case 'onclicked':
				for( var i=0; i<this.onclicked.length; i++ ){
					if(this.onclicked[i].onclicked){
						this.onclicked[i].onclicked();
					}else{
						window.status=this.toString()+'类的某'+estring+'事件监听对象损坏';
					}
				}
			break;
			default:
				window.status = this.toString()+'类不存在'+estring+'事件';
			break;
		}
	}
}